package com.soladhoc.webapps.shared;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
import com.soladhoc.webapps.client.domain.Announce;

public class NewAnnounceEvent extends
		GwtEvent<NewAnnounceEvent.NewAnnounceHandler> {

	public static Type<NewAnnounceHandler> TYPE = new Type<NewAnnounceHandler>();
	private Announce announce;

	public interface NewAnnounceHandler extends EventHandler {
		public void onNewAnnounce(NewAnnounceEvent event);
	}

	public interface NewAnnounceHasHandlers extends HasHandlers {
		public HandlerRegistration addNewAnnounceHandler(NewAnnounceHandler handler);
	}

	public NewAnnounceEvent(Announce announce) {
		this.announce = announce;
	}

	public Announce getAnnounce() {
		return announce;
	}

	@Override
	protected void dispatch(NewAnnounceHandler handler) {
		handler.onNewAnnounce(this);
	}

	@Override
	public Type<NewAnnounceHandler> getAssociatedType() {
		return TYPE;
	}

	public static Type<NewAnnounceHandler> getType() {
		return TYPE;
	}

	public static void fire(HasHandlers source, Announce announce) {
		source.fireEvent(new NewAnnounceEvent(announce));
	}
}
